﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace shenghua.Migrations
{
    public partial class addentity5 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "WordNode");

            migrationBuilder.DropPrimaryKey(
                name: "PK_WordNodes",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "Classes_Class1",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Classes_Class2",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Discount",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "NeededXP",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "AddedFreightValue",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "WordNodes");

            migrationBuilder.RenameTable(
                name: "WordNodes",
                newName: "ShippingTemplates");

            migrationBuilder.RenameColumn(
                name: "Classes_Class3",
                table: "Commodities",
                newName: "Classes_StringValue");

            migrationBuilder.AddColumn<string>(
                name: "Description",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "DisplayName",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "Enabled",
                table: "FileItems",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "Icon",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsDefault",
                table: "FileItems",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsFolder",
                table: "FileItems",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "LinkAddress",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "OnlyMemberVisible",
                table: "FileItems",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<int>(
                name: "ParentId",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Sort",
                table: "FileItems",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "Tag",
                table: "FileItems",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Type",
                table: "FileItems",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AlterColumn<int>(
                name: "TemplateType",
                table: "ShippingTemplates",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "FirstNumber",
                table: "ShippingTemplates",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "AddedNumber",
                table: "ShippingTemplates",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AddColumn<int>(
                name: "AddedFreight_MoneyType",
                table: "ShippingTemplates",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<double>(
                name: "AddedFreight_Value",
                table: "ShippingTemplates",
                nullable: false,
                defaultValue: 0.0);

            migrationBuilder.AddColumn<int>(
                name: "Freight_MoneyType",
                table: "ShippingTemplates",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<double>(
                name: "Freight_Value",
                table: "ShippingTemplates",
                nullable: false,
                defaultValue: 0.0);

            migrationBuilder.AddPrimaryKey(
                name: "PK_ShippingTemplates",
                table: "ShippingTemplates",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "Areas",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Areas", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommodityClasses",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityClasses", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommodityShoppingOptionParameters",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityShoppingOptionParameters", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommoditySpecificationParameters",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommoditySpecificationParameters", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommodityWares",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityWares", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "FriendlyLinks",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FriendlyLinks", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Guarantees",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Guarantees", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MemberFormItems",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MemberFormItems", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MemberGroups",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MemberGroups", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MemberLevels",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ParentId = table.Column<int>(nullable: true),
                    Tag = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    LinkAddress = table.Column<string>(nullable: true),
                    Icon = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    OnlyMemberVisible = table.Column<bool>(nullable: false),
                    NeededXP = table.Column<int>(nullable: false),
                    Discount = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MemberLevels", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Areas");

            migrationBuilder.DropTable(
                name: "CommodityClasses");

            migrationBuilder.DropTable(
                name: "CommodityShoppingOptionParameters");

            migrationBuilder.DropTable(
                name: "CommoditySpecificationParameters");

            migrationBuilder.DropTable(
                name: "CommodityWares");

            migrationBuilder.DropTable(
                name: "FriendlyLinks");

            migrationBuilder.DropTable(
                name: "Guarantees");

            migrationBuilder.DropTable(
                name: "MemberFormItems");

            migrationBuilder.DropTable(
                name: "MemberGroups");

            migrationBuilder.DropTable(
                name: "MemberLevels");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ShippingTemplates",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "Description",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "DisplayName",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "Enabled",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "Icon",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "IsDefault",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "IsFolder",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "LinkAddress",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "OnlyMemberVisible",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "ParentId",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "Sort",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "Tag",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "Type",
                table: "FileItems");

            migrationBuilder.DropColumn(
                name: "AddedFreight_MoneyType",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "AddedFreight_Value",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "Freight_MoneyType",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "Freight_Value",
                table: "ShippingTemplates");

            migrationBuilder.RenameTable(
                name: "ShippingTemplates",
                newName: "WordNodes");

            migrationBuilder.RenameColumn(
                name: "Classes_StringValue",
                table: "Commodities",
                newName: "Classes_Class3");

            migrationBuilder.AddColumn<string>(
                name: "Classes_Class1",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Classes_Class2",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "TemplateType",
                table: "WordNodes",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<int>(
                name: "FirstNumber",
                table: "WordNodes",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<int>(
                name: "AddedNumber",
                table: "WordNodes",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AddColumn<double>(
                name: "Discount",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "NeededXP",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<double>(
                name: "AddedFreightValue",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Discriminator",
                table: "WordNodes",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddPrimaryKey(
                name: "PK_WordNodes",
                table: "WordNodes",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "WordNode",
                columns: table => new
                {
                    ShippingTemplateId = table.Column<int>(nullable: false),
                    MoneyType = table.Column<int>(nullable: false),
                    Value = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WordNode", x => x.ShippingTemplateId);
                    table.ForeignKey(
                        name: "FK_WordNode_WordNodes_ShippingTemplateId",
                        column: x => x.ShippingTemplateId,
                        principalTable: "WordNodes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
        }
    }
}
